package com.ang.service2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * javaBean声明式事务
 * 基于javaBean配置类，加载数据源等信息，并配置扫描包，开启事务注解支持
 */
@Component
public class TestService2 {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Transactional
    public void test1() {
        jdbcTemplate.update("update t_user set age = ? where id = ?", 1, 1);
//        int i = 1 / 0;
    }

}
